package session;

import dao.User;

import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

public class Session{
    public static User isLogin(HttpServletRequest req){
        HttpSession httpSession = req.getSession(false);
        if (httpSession == null){
            System.out.println("未登录状态");
            return null;
        }
        User user = (User) httpSession.getAttribute("user");
        if (user == null){
            System.out.println("未登录状态");
            return null;
        }
        return user;
    }
}
